<template>
<div class="wrapper">
  <swiper :options="swiperOption" >
    <swiper-slide  class="page" v-for="(page,index) of sortList" :key="index">
      <div class="page__item" v-for="item of page" :key="item.id">
        <img :src="item.imgUrl" alt="">
        <div class="des">{{item.desc}}</div>
      </div>
    </swiper-slide>
    <!-- Optional controls -->
    <div class="swiper-pagination"  slot="pagination"></div>
  </swiper>
</div>
</template>

<script>
export default {
  name: 'Shotcut',
  props: {
    itemList: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        }
      }
    }
  },
  computed: {
    sortList () {
      const getList = []
      this.itemList.forEach((item, index) => {
        const listNum = Math.floor(index / 8)
        if (!getList[listNum]) {
          getList[listNum] = []
        }
        getList[listNum].push(item)
      })
      return getList
    }
  }
/*  created () {
    for (var i = 0; i < this.itemList.length; i++) {
      const pageNum = Math.floor(i / 8)
      if (!this.sortList[pageNum]) {
        this.sortList[pageNum] = []
      }
      this.sortList[pageNum].push(this.itemList[i])
    }
    console.log(this.sortList)
  } */
}
</script>

<style lang="stylus" scoped>
@import '~@style/variables.styl'
  .wrapper >>> .swiper-container
    padding-bottom 20px
    .swiper-pagination
      bottom 4px
      .swiper-pagination-bullet
        height 6px
        width 6px
        background-color #000
      .swiper-pagination-bullet-active
        background-color $bgcolor
  .wrapper
    height 0
    padding-bottom 46%
    overflow hidden
    .page
      display flex
      flex-wrap wrap
      &__item
        width 25%
        text-align center
        img
          width 53.1%
          margin-top 10px
        .des
          margin-top 6px

</style>
